package org.vidi.amqp.basic;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import org.vidi.amqp.common.ConnectionUtils;
import org.vidi.amqp.common.Constants;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author vidi
 */
public class BasicProducer {
    public static void main(String[] args) {
        try (Connection connection = ConnectionUtils.newSingleConnection();
             Channel channel = connection.createChannel()) {
            channel.queueDeclare(Constants.BASIC_QUEUE_NAME, false, false, false, null);
            byte[] message = "Hello, world.".getBytes();
            channel.basicPublish("", Constants.BASIC_QUEUE_NAME, null, message);
        } catch (IOException | TimeoutException e) {
            e.printStackTrace();
        }
    }
}
